package com.lotter.common.enumobject;

import com.lotter.common.util.StringUtil;

//进球
public enum GoalEnum {

	
	 G_1(1, "0球", 0),
	 G_2(2, "1球", 1),
	 G_3(3, "2球", 2),
	 G_4(4, "3球", 3),
	 G_5(5, "4球", 4),
	 G_6(6, "5球", 5),
	 G_7(7, "6球", 6),
	 G_8(8, "7+球", 7);

	private int code;
	
	private String desc;
	
	private int num ;



	public int getCode() {
		return code;
	}

	public String getDesc() {
		return desc;
	}
	
	
	
	/**
	 * @return the num
	 */
	public int getNum() {
		return num;
	}

	/**
	 * @param num the num to set
	 */
	public void setNum(int num) {
		this.num = num;
	}

	/**
	 * @param code the code to set
	 */
	public void setCode(int code) {
		this.code = code;
	}

	/**
	 * @param desc the desc to set
	 */
	public void setDesc(String desc) {
		this.desc = desc;
	}
	
	

	private GoalEnum(int code, String desc, int num) {
		this.code = code;
		this.desc = desc;
		this.num = num;
	}

	public static Integer judgeCode(String scope){
		if(StringUtil.isBlank(scope)){
			return null;
		}
		String[] arrayScore = scope.split(":");
		int home = Integer.parseInt(arrayScore[0]);
		int away = Integer.parseInt(arrayScore[1]);
		int code  = 1 ;
		
		int temp = home + away ;
		for (GoalEnum type : values()) {
			if(temp > type.getNum()){
				continue;
			}else if(temp == type.getNum()){
				code = type.getCode();
				break;
			}else{
				return code ;
			}
		}
		
		return code ;
	}
	
	


	
}
